#define STAT        atestdata[1]
#define Test        atestdata[2]
#define SHAPINGSTAT atestdata[3] 
awaitstatus[16],1
awaittime,1000
amotionmode=1
STAT=0
Test=0
SHAPINGSTAT=0
adoutport=0
while(1)
    if(SHAPINGSTAT==0)
           if((STAT==0)&&(!amotionstat))
             awaittime=500
             amotoron=0
             awaittime=100
             aspeed=10000
             aabstrgt=53666
             ashapingon=0
             amotoron=1
             abegin
             STAT=1
           end
           if((STAT==1)&&(!amotionstat)&&(adinport==4))
             awaittime=1500
             amotoron=0
             awaittime=100
             aspeed=200000
             aabstrgt=83707
             ashapingon=0
             amotoron=1
             abegin
             STAT=2
            end
           if((STAT==2)&&(!amotionstat)&&(adinport==4))
             awaittime=1500
             amotoron=0
             awaittime=100
             aspeed=200000
             aabstrgt=53666
             ashapingon=0
             amotoron=1
             abegin
             STAT=3
            end
          if((STAT==3)&&(!amotionstat)&&(adinport==4))
		   if(Test<2)
		     STAT=1
		     Test++
		     end
		   if(Test>1)
	         Test=0
              awaittime=5000
	         STAT=4
	         SHAPINGSTAT=1
	         end
             end
         end
	if(SHAPINGSTAT==1)
          if((STAT==4)&&(!amotionstat)&&(adinport==4))
             awaittime=1500
             amotoron=0
             awaittime=100
             ashapingfreq[1]=655360
             ashapingfreq[2]=393216 
	     ashapingon=1
             aspeed=2621440
             aabstrgt=83707
             amotoron=1
             abegin
             STAT=5
             end
           if((STAT==5)&&(!amotionstat)&&(adinport==4))
             awaittime=1500
	     amotoron=0
             awaittime=100
             ashapingfreq[1]=655360
             ashapingfreq[2]=393216  
	     ashapingon=1
             aspeed=2621440
             aabstrgt=53666
             amotoron=1
             abegin
             STAT=6
             end
	   if((STAT==6)&&(!amotionstat)&&(adinport==4))
		   if(Test<2)
		     STAT=4
		     Test++
		     end
		   if(Test>1)
	         Test=0
	         STAT=1
	         SHAPINGSTAT=0
             end
       end
   end
end